package ClassesBasicas;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "paciente")
@PrimaryKeyJoinColumn(name = "codigo_pessoa")		
public class Paciente extends Pessoa{
	
	@ManyToOne(fetch = FetchType.EAGER)	
	@JoinColumn(name = "convenio_codigo", 
						insertable = true, updatable = true)
	@Fetch(FetchMode.JOIN)	
	@Cascade(CascadeType.SAVE_UPDATE)
	private Convenio convenio;
	
	public Paciente(){
		
	}
	
	public Paciente(String nome, String cpf, char sexo, Date date, Endereco endereco, Convenio convenio){
		super(nome, cpf, sexo, date, endereco);
		setConvenio(convenio);
	}
	
	public Convenio getConvenio() {
		return convenio;
	}
	public void setConvenio(Convenio convenio) {
		this.convenio = convenio;
	}
	@Override
	public Endereco getEndereco(){
		return super.getEndereco();	
	}	

}
